"""
@author: csy
@file: 密码复杂度.py
@time: 2023/11/28 21:57
"""
import re

def password_complexity_score(password):
    # Check length
    if len(password) < 8:
        return 2


    conditions_met = sum([any(c.isupper() for c in password),
                         any(c.islower() for c in password),
                         any(c.isdigit() for c in password),
                         any(c.isascii() and not c.isalnum() for c in password)])


    for i in range(len(password) - 2):
        substr = password[i:i + 3]
        if password.count(substr) > 1:
            return 2


    score = 2 + conditions_met

    return score


password = input("Enter your password: ")


score = password_complexity_score(password)

print(f"Password Complexity Score: {score}")
